package com.hmdp.controller;


import com.hmdp.dto.Result;
import com.hmdp.entity.User;
import com.hmdp.service.IFollowService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 虎哥
 * @since 2021-12-22
 */
@RestController
@RequestMapping("/follow")
public class FollowController {

    @Resource
    private IFollowService followService;

    /**
     * 关注或取关该文章的博主
     */
    @PutMapping("/{id}/{isFollow}")
    public Result follow(@PathVariable("id") Long followUserId, @PathVariable("isFollow") Boolean isFollow){

        return followService.follow(followUserId, isFollow);
    }

    /**
     * 判断当前用户是否关注了此用户
     * @return
     */
    @GetMapping("/or/not/{id}")
    public Result followed(@PathVariable("id") Long followedUserId){
        //传入的参数是判断是否被当前用户关注的用户id

        return followService.isFollowed(followedUserId);
    }

    @GetMapping("/common/{id}")
    public Result common(@PathVariable("id") Long OtherUserId){

        return followService.commonFollow(OtherUserId);
    }

}
